package com.example.demo2_review.design_pattern.concurrency_patterns.producer_consumer_Pattern;

import static com.example.demo2_review.pojo.common.BaseConstants1.NUM_FIVE;

/**
 * @Author zwp14
 * @create 2024/6/25 1:39
 * @description
 */
public record Consumer(Buffer1 buffer1) implements Runnable{


    @Override
    public void run() {

        for (int i = 0; i < NUM_FIVE; i++) {
            try {
                int value = buffer1.consume();
                Thread.sleep(2000);
                System.out.println("消费者成功消费到物品："+value);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
